{template header}
    <header>
        <a href="javascript:;" onClick="javascript :history.back(-1);" class="headerL iconfont">&#xe66a;</a>
        <h1>交易详情</h1>
    </header>
    <!-- E header -->
    <!-- S 交易状态 -->
    <dl class="my_deal_condition">
        <dt><img src="{THEME_PATH}images/deal2.png" alt="" width="102" class="ico"></dt>
        <dd class="tit">等待确认</dd>
        <dd id="c_down_">--</dd>
    </dl>
    <script type="text/javascript">
        $(function(){
            countDown(<?php echo $tinfo['ctime']?>);
        })
    </script>
    <!-- E 交易状态 -->
<?php if($tinfo['sell_id']==$this->userinfo['id']) {?>
    <h2 class="my_deal_h2">转账会员信息</h2>
    <ul class="flex my_deal_user">
        <li><img src="<?php echo get_avatar($buyer['ico']);?>" alt="" width="50" class="user_photo"></li>
        <li>
            <dl>
                <dt class="user_name">{$buyer[username]}</dt>
                <dd>{$buyer[mobile_phone]}</dd>
            </dl>
        </li>
    </ul>
    <!-- S 交易信息 -->
    <h2 class="my_deal_h2">交易信息</h2>
    <ul class="my_deal_msg_items">
        <li class="flex flex-pack-justify">
            <div>编号</div>
            <div>{$tinfo[order_sn]}</div>
        </li>
        <li class="flex flex-pack-justify">
            <div>数量(DBT)</div>
            <div>{$tinfo[num]}</div>
        </li>
        <li class="flex flex-pack-justify">
            <div>单价(USD)</div>
            <div>{$tinfo[price]}</div>
        </li>
        <li class="flex flex-pack-justify">
            <div>总价(USD)</div>
            <div>{$tinfo[amount]}</div>
        </li>
        <li class="flex flex-pack-justify">
            <div>总价(CNY)</div>
            <div>{$tinfo[cny]}</div>
        </li>

        <li class="flex flex-pack-justify">
            <div>时间</div>
            <div>2018-8-1 14:00:13</div>
        </li>
    </ul>
    <!-- E 交易信息 -->
    <h2 class="my_deal_h2">转账截图</h2>
    <div class="my_deal_screenshot">
        <img src="<?php echo $tinfo['pic']==""?"/template/wap/statics/images/proof.png":$tinfo['pic'];?>" alt="" class="img-responsive">
    </div>
    <div class="my_deal_btnBox flex flex-pack-justify">
        <a href="javascript:void(0);" class="button button1" onclick="complainBtn()">投诉</a>
        <a href="javascript:void(0);" class="button button2" onclick="confirm()">确认收款</a>
    </div>
<?php }?>
<?php if($tinfo['user_id']==$this->userinfo['id']) {?>
    <!-- S 会员信息 -->
    <h2 class="my_deal_h2">转账会员信息</h2>
    <ul class="flex my_deal_user">
        <li><img src="<?php echo get_avatar($seller['ico']);?>" alt="" width="50" class="user_photo"></li>
        <li>
            <dl>
                <dt class="user_name">{$seller[username]}</dt>
                <dd>{$seller[mobile_phone]}</dd>
            </dl>
        </li>
    </ul>
    <ul class="my_deal_msg_items">
        <li class="flex flex-pack-justify">
            <div>真实姓名</div>
            <div>{$seller[true_name]}</div>
        </li>
        <li class="flex flex-pack-justify">
            <div>支付宝账号</div>
            <div>{$seller[alipay]} <i onclick="showimg('{$seller[alipay_qr]}')" class="iconfont font24 verticalM">&#xe60c;</i></div>
        </li>
        <li class="flex flex-pack-justify">
            <div>微信账号</div>
            <div>{$seller[weixin]} <i onclick="showimg('{$seller[weixin_qr]}')" class="iconfont font24 verticalM">&#xe60c;</i></div>
        </li>
        <li class="flex flex-pack-justify">
            <div>银行账号</div>
            <div>{$seller[banknum]}({$seller[bankaddress]})</div>
        </li>
    </ul>
    <!-- E 会员信息 -->
    <!-- S 交易信息 -->
    <h2 class="my_deal_h2">交易信息</h2>
    <ul class="my_deal_msg_items">
        <li class="flex flex-pack-justify">
            <div>编号</div>
            <div>{$tinfo[order_sn]}</div>
        </li>
        <li class="flex flex-pack-justify">
            <div>数量(DBT)</div>
            <div>{$tinfo[num]}</div>
        </li>
        <li class="flex flex-pack-justify">
            <div>单价(USD)</div>
            <div>{$tinfo[price]}</div>
        </li>
        <li class="flex flex-pack-justify">
            <div>总价(USD)</div>
            <div>{$tinfo[amount]}</div>
        </li>
        <li class="flex flex-pack-justify">
            <div>总价(CNY)</div>
            <div>{$tinfo[cny]}</div>
        </li>
        
        <li class="flex flex-pack-justify">
            <div>时间</div>
            <div>2018-8-1 14:00:13</div>
        </li>
    </ul>
    <!-- E 交易信息 -->
   <!-- S 上传转账截图 -->
    <h2 class="my_deal_h2">上传转账截图</h2>
    <div class="my_deal_screenshot">
        <img src="<?php echo $tinfo['pic']==""?"/template/wap/statics/images/proof.png":$tinfo['pic'];?>" alt="" class="img-responsive">
    </div>
    <!-- E 上传转账截图 -->
    <div class="my_deal_btnBox flex flex-pack-justify">
        <a href="javascript:void(0);" class="button button1" onclick="complainBtn()">投诉</a>
        <?php if($tinfo['sell_id']==$this->userinfo['id']){?>
        <a href="javascript:void(0);" class="button button2" onclick="affirmBtn()">确认</a>
        <?php }?>
    </div>
<?php }?>   
    <div class="popup_shade"></div>
    <div class="complain_popUp">
        <h2 class="title alignC">投诉理由</h2>
        <textarea name="complain" class="text" id="complain" placeholder="请输入投诉理由..."></textarea>
        <ul class="evaluate_btn_box flex flex-pack-justify">
            <li><a href="javascript:void(0);" class="btn btn1" onclick="complainClose();">取消</a></li>
            <li><a href="javascript:void(0);" class="btn btn2" onclick="complainSubmit();">完成</a></li>
        </ul>
    </div>
<style type="text/css">
    .imgpop{ position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: #eee; display: none }
    .imgpop img{ width: 100%; height: auto; margin-top: 50px; }
    #imgclose{ height: 30px; width: 50px; line-height: 30px; position: fixed; top: 10px; right: 10px;  border-radius: 5px; background-color: #333; color: #fff;
    text-align: center; font-size: 14px; }
</style>
    
<div class="imgpop">
    <span id="imgclose" onclick="closeimg();">关闭</span>
    <img src="" >
</div>

</body>
<script>
    //投诉
    function complainBtn(){
        $(".popup_shade,.complain_popUp").show();
    }
    function complainClose(){
        $(".popup_shade,.complain_popUp").hide();
    }
    function complainSubmit(){
        var complain = $("#complain").val();
        var id = <?php echo $tinfo['id']?>;
        $.ajax({
            type:'post',
            url:'/index.php?m=user&c=trade&a=complainadd',
            data:{id:id,complain:complain},
            dataType:'json',
            success:function(ret){
              layer.closeAll();
              console.log(ret);
              if(ret.status==1){
                  tips(ret.info,'/index.php?m=user&c=trade&a=tradedetail&id=<?php echo $tinfo['id']?>');
              }else{
                  hd_alert(ret.info);
              }
            }
        })
    }
    // 确认收款
    function confirm(){
        var id = <?php echo $tinfo['id']?>;
        $.ajax({
            type:'post',
            url:'/index.php?m=user&c=trade&a=confirmorder',
            data:{id:id},
            dataType:'json',
            success:function(ret){
              layer.closeAll();
              console.log(ret);
              if(ret.status==1){
                  tips(ret.info,'/index.php?m=user&c=trade&a=tradedetail&id=<?php echo $tinfo['id']?>');
              }else{
                  hd_alert(ret.info);
              }
            }
        })
    }

function countDown(times){
  var timer=null;
  timer=setInterval(function(){
    var day=0,
      hour=0,
      minute=0,
      second=0;//时间默认值
    if(times > 0){
      // day = Math.floor(times / (60 * 60 * 24));
      hour = Math.floor(times / (60 * 60)) - (day * 24);
      minute = Math.floor(times / 60) - (day * 24 * 60) - (hour * 60);
      second = Math.floor(times) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
    }
    // if (day <= 9) day = '0' + day;
    if (hour <= 9) hour = '0' + hour;
    if (minute <= 9) minute = '0' + minute;
    if (second <= 9) second = '0' + second;
    $("#c_down_").html("倒计时&nbsp;"+hour+":"+minute+":"+second);
    // console.log(hour+":"+minute+":"+second);
    times--;
  },1000);
  if(times<=0){
    clearInterval(timer);
  }
}

function showimg(url){
    $(".imgpop img").attr("src",url);
    $(".imgpop").show();
}
function closeimg(){
    $(".imgpop img").attr("src","");
    $(".imgpop").hide();  
}

</script>
</html>